<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <title>云纵停车开放网关测试</title>
    <style type="text/css">
        table
        {border-collapse: collapse;margin: 0 auto;text-align:left;font-size:16px;font-family:微软雅黑;font-color:"black";}
        table td, table th
        {border: 1px solid #cad9ea;color: #666;height: 30px;}
        table thead th
        {background-color: #CCE8EB;width: 100px;}
        table tr:nth-child(odd)
        {background: #fff;}
        table tr:nth-child(even)
        {background: #F5FAFA;}
        input[type=text]
        {width: 600px;}
        input[type=button]
        {width: 100px;}
        input[type=submit]
        {width: 200px; height: 30px;}
    </style>
</head>

<body>
    <form action="http://localhost:8888/parking/sendAuthOpenid" name="returnfunc" id= "returnfunc" method="post">
        <table width="90%" class="table">
            <caption>
                <h2>授权获取openid测试</h2>
            </caption>
            <thead>
                <tr>
                    <th width="25%"><b>英文名称</b></th>
                    <th width="25%"><b>中文名称</b></th>
                    <th width="50%"><b>参数值</b></th>
                </tr>
            </thead>
            <tr>
                <td>api_name</td>
                <td>接口名称</td>
                <td><input type="text" name="api_name" id="api_name" value="yz.trade.pay"/></td>
            </tr>
            <tr>
                <td>service_name</td>
                <td>机构号</td>
                <td><input type="text" name="service_name" id="service_name" value="1232131212132"/></td>
            </tr>
            <tr>
                <td>timestamp</td>
                <td>时间戳</td>
                <td>
                    <input type="text" name="timestamp" id="timestamp" value=""/>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="button" value="获取" onclick="getTimestampStr();"/>
                </td>
            </tr>
            <tr>
                <td>charset</td>
                <td>字符编码</td>
                <td><input type="text" name="charset" id="charset" value="UTF-8"/></td>
            </tr>
            <tr>
                <td>version</td>
                <td>版本编号</td>
                <td><input type="text" name="version" id="version" value="1.0"/></td>
            </tr>
            <tr>
                <td>sign_type</td>
                <td>签名类型</td>
                <td><input type="text" name="sign_type" id="sign_type" value="RSA"/></td>
            </tr>
            <tr>
                <td>app_auth_token</td>
                <td>授权token</td>
                <td><input type="text" name="app_auth_token" id="app_auth_token" value=""/></td>
            </tr>
            <tr>
                <td>redirect_url</td>
                <td>H5收银台完整路径</td>
                <td><input type="text" name="redirect_url" id="redirect_url" value=""/></td>
            </tr>
            <tr>
                <td>sign</td>
                <td>签名</td>
                <td>
                    <textarea rows="3" cols="50" id="sign" name="sign"></textarea>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="button"value="获取" onclick="getSign();"/>
                </td>
            </tr>
            <tr>
                <td width="100%" colspan="3" align="center">
                    <input type="hidden" id="pageType" name="pageType" value="authOpenid">
                    <input type="submit" value="提交"/>
                </td>
            </tr>
        </table>
    </form>

    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script type="text/javascript">
        function getTimestampStr() {
            $.ajax({
                type : "GET",
                url : "http://localhost:8888/parking/getTimestamp",
                dataType : "json", //预期服务器返回的数据
                success : function(data) {
                    $("#timestamp").val(data.timestampStr)
                },
            });
        }

        function getOutTradeNo() {
            $.ajax({
                type : "GET",
                url : "http://localhost:8888/parking/getOutTradeNo",
                dataType : "json", //预期服务器返回的数据
                success : function(data) {
                    $("#out_trade_no").val(data.outTradeNoStr)
                },
            });
        }

        function getSign() {
            $.ajax({
                type : "GET",
                url : "http://localhost:8888/parking/getSign",
                data : {
                    api_name : $("#api_name").val(),
                    service_name : $("#service_name").val(),
                    timestamp : $("#timestamp").val(),
                    charset : $("#charset").val(),
                    version : $("#version").val(),
                    sign : $("#sign").text(),
                    sign_type : $("#sign_type").val(),
                    app_auth_token : $("#app_auth_token").val(),
                    redirect_url : $("#redirect_url").val(),
                    pageType : $("#pageType").val()
                },
                dataType : "json", //预期服务器返回的数据
                success : function(data) {
                    $("#sign").text(data.signStr)
                },
            });
        }
    </script>

</body>

</html>
